package com.tps.eric.service;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

public class DynamicQueryProvider {

    public static String queryList(@Param("tableName") String tableName, @Param("fields") String fields, @Param("condition") String condition) {
        return new SQL(){{
            if (fields == null){
                SELECT("*");
            }else {
                SELECT(fields);
            }
            FROM(tableName);
            if (condition != null){
                WHERE(condition);
            }
        }}.toString();
    }
}
